<template>
  <div>
    <div class="search_title">历史搜索
      <i class="el-icon-delete delete_icon" @click="delHistory"></i>
    </div>
    <div :class="[tagShow===0?'search_history':'search_history_show']">
      <div class="tag" v-for="(item,i) in tagHistoryList" @click="doSearch(item)" v-if="i<8?true:tagShow===1">
        {{item}}
      </div>
    </div>
  </div>

</template>

<script>
export default {
  name: "searchHistory",//搜索历史
  props:{tagList:{type:Array}},
  data(){
    return{
      tagShow:0,
      tagHistoryList:this.tagList
    }
  },
  methods:{
    doSearch(item){
      if(item==='▼'){
        this.tagShow=1
        this.tagHistoryList.splice(7,1)

      }else {
        this.$emit('do-search',item)

      }
    },
    delHistory(){
      this.tagHistoryList=[]
    }
  }
}
</script>

<style scoped>
.search_title{
  text-align: left;
  margin-left: 20px;
  font-size: 26px;
  font-weight: normal;
  color: #333333;
  line-height: 32px;
}
.search_history_show{
  background: white;
  display: flex;
  flex-wrap: wrap;
  padding: 0 30px;
}
.search_history{
  height: 180px;
  overflow: hidden;
  background: white;
  display: flex;
  flex-wrap: wrap;
  padding: 0 30px;
}
.search_history .tag:nth-child(8){
  background: #FFFFFF;
  color: #9A9A9A;
}
.tag{
  padding: 0px 20px;
  height: 63px;
  line-height: 63px;
  background: #F7F7F7;
  border-radius: 28px;
  color: #666666;
  text-align: center;
  margin-top: 20px;
  margin-right: 20px;
}
.delete_icon{
  position: absolute;
  right: 50px;
}
</style>
